import { IHistory } from "@/model/History";
import { GameType } from "@/model/GameType";
import md5 from "md5";

export interface IHistoryInfo {
  Type?: GameType;
  CrateTime?: Date;
  SaveTime?: Date;
  Histories?: IHistory[];
  ID?: string;
}

export class DefaultHistoryInfo implements IHistoryInfo {
  public Histories = [];
  public ID: string;
  public CrateTime = new Date();
  public SaveTime = new Date();
  public Type = GameType.NumGuess;

  constructor() {
    this.ID = this.genID();
  }

  private genID(): string {
    let tmpStr = "" + this.CrateTime.getTime(); // 1616 4193 8185 2
    tmpStr += md5(tmpStr + "&History").slice(0, 9);
    return tmpStr.toUpperCase();
  }
}
